/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entity;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author adama
 */
@Entity
@Table(name = "relationvideoartiste")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Relationvideoartiste.findAll", query = "SELECT r FROM Relationvideoartiste r"),
    @NamedQuery(name = "Relationvideoartiste.findByIdRelationVideoArtiste", query = "SELECT r FROM Relationvideoartiste r WHERE r.relationvideoartistePK.idRelationVideoArtiste = :idRelationVideoArtiste"),
    @NamedQuery(name = "Relationvideoartiste.findByRole", query = "SELECT r FROM Relationvideoartiste r WHERE r.role = :role"),
    @NamedQuery(name = "Relationvideoartiste.findByIdVideo", query = "SELECT r FROM Relationvideoartiste r WHERE r.relationvideoartistePK.idVideo = :idVideo")})
public class Relationvideoartiste implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected RelationvideoartistePK relationvideoartistePK;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 10)
    @Column(name = "Role")
    private String role;
    @JoinColumn(name = "IdVideo", referencedColumnName = "idVideo", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Video video;
    @JoinColumn(name = "IdProducteur", referencedColumnName = "idPersonne")
    @ManyToOne
    private Personne idProducteur;
    @JoinColumn(name = "IdActeur", referencedColumnName = "idArtiste")
    @ManyToOne
    private Artiste idActeur;

    public Relationvideoartiste() {
    }

    public Relationvideoartiste(RelationvideoartistePK relationvideoartistePK) {
        this.relationvideoartistePK = relationvideoartistePK;
    }

    public Relationvideoartiste(RelationvideoartistePK relationvideoartistePK, String role) {
        this.relationvideoartistePK = relationvideoartistePK;
        this.role = role;
    }

    public Relationvideoartiste(int idRelationVideoArtiste, int idVideo) {
        this.relationvideoartistePK = new RelationvideoartistePK(idRelationVideoArtiste, idVideo);
    }

    public RelationvideoartistePK getRelationvideoartistePK() {
        return relationvideoartistePK;
    }

    public void setRelationvideoartistePK(RelationvideoartistePK relationvideoartistePK) {
        this.relationvideoartistePK = relationvideoartistePK;
    }

    public String getRole() {
        return role;
    }

    public void setRole(String role) {
        this.role = role;
    }

    public Video getVideo() {
        return video;
    }

    public void setVideo(Video video) {
        this.video = video;
    }

    public Personne getIdProducteur() {
        return idProducteur;
    }

    public void setIdProducteur(Personne idProducteur) {
        this.idProducteur = idProducteur;
    }

    public Artiste getIdActeur() {
        return idActeur;
    }

    public void setIdActeur(Artiste idActeur) {
        this.idActeur = idActeur;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (relationvideoartistePK != null ? relationvideoartistePK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Relationvideoartiste)) {
            return false;
        }
        Relationvideoartiste other = (Relationvideoartiste) object;
        if ((this.relationvideoartistePK == null && other.relationvideoartistePK != null) || (this.relationvideoartistePK != null && !this.relationvideoartistePK.equals(other.relationvideoartistePK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entity.Relationvideoartiste[ relationvideoartistePK=" + relationvideoartistePK + " ]";
    }
    
}
